package com.borqs.samples;

import android.content.Context;
import android.os.ServiceManager;
import android.os.Parcel;
import android.os.IBinder;
import android.util.Log;
import java.util.Map;
import java.util.HashMap;
import java.util.List;
import java.util.ArrayList;
import java.util.Arrays;

public class WakelockServiceProvider{
    public static final String TAG = "WakelockServiceProvider";
    static final int TRANSACTION_BORQS_BASE = (android.os.IBinder.FIRST_CALL_TRANSACTION + 1000);
    static final int TRANSACTION_BORQS_getNowMaxPartialWl = (TRANSACTION_BORQS_BASE + 1);

    public static String[] getNowMaxPartialWl(){
        IBinder client = (IBinder)ServiceManager.getService(Context.POWER_SERVICE);
        String[] result = null;
        if(client == null) {
            Log.e(TAG,"in getNowMaxPartialWl,the service proxy is null");
            return null;
        }
        boolean ret = false;
        Parcel data = Parcel.obtain();
        Parcel reply = Parcel.obtain();
        try {
            data.writeInterfaceToken("android.os.IPowerManager");
            ret = client.transact(TRANSACTION_BORQS_getNowMaxPartialWl,data,reply,0);
            if(ret) {
                result = reply.readStringArray();
            }
            else Log.i(TAG,"in getNowMaxPartialWl,PowerManagerService's transact return false");
        } catch (Exception e) {
            Log.e(TAG,"getNowMaxPartialWl transaction exception: "+e);
        } finally {
            reply.recycle();
            data.recycle();
        }
        return result;
    }
}
